Hi, could someone please tell me why operador overloading (https://dlang.org/spec/operatoroverloading.html) is relegated only to classes and structs?

"1 Operator overloading is accomplished by rewriting operators whose operands are class or struct objects into calls to specially named members. No additional syntax is used."

I'd like to overload "~" to concatenate a string with a integer and do something else, like:

  auto s = "1" ~ 2;

But what I've tried so far didn't work.

If that constraint (Classes and Structs) is true, why?

Thanks,

Matheus.

Reply via email to