Should we add `a * b` for vectors?

Steven Schveighoffer schveiguy at yahoo.com
Wed Oct 4 00:24:41 UTC 2017


On 10/3/17 3:25 PM, Walter Bright wrote:
> This is specifically designed to prevent nasty surprises. C++ has a big 
> problem with ADL in that overloading is not encapsulated and any 
> #included header can inadvertently add more overloads that may be 
> entirely unrelated. Any .h can crack open any namespace and insert more 
> overloads into it. It's completely unhygienic and uncontrollable.

One thing I would like to have control over is how 'this' is passed.

A nice thing about UFCS is I can use it to pass-by-value the faux 'this' 
parameter, whereas I cannot do this with a member function. It makes a 
difference in some cases, especially with const functions.

It also can be cheaper to pass a small struct by value.

None of this is possible with operator overloading. A way out could 
possibly be to alias a non-member function for the operator.

-Steve


More information about the Digitalmars-d mailing list