opAssign and const?
Era Scarecrow
rtcvb32 at yahoo.com
Thu May 3 23:32:40 PDT 2012
On Friday, 4 May 2012 at 06:15:21 UTC, Jonathan M Davis wrote:
> I believe that the issue is that x2 isn't const, so when the
> compiler decides which of the two overloads to use, it picks
> the one which doesn't use const. If the const ref version were
> the only one, then it would work with x2, but since it isn't,
> the other one gets picked because it's deemed a better match.
I figured that was the case too. But I get the feeling that's
wrong in this case. I was hoping to have only two declared
opAssing's, one for temporaries (without ref) and one for
copying. Kinda like the difference between saying a=b and a[]=b[]
for an array. Be annoying if I had to force the cast to be const
to do what I wanted; Right?
More information about the Digitalmars-d-learn
mailing list