opAssign and const?

Jonathan M Davis jmdavisProg at gmx.com
Thu May 3 23:55:32 PDT 2012


On Friday, May 04, 2012 08:52:49 Era Scarecrow wrote:
> On Friday, 4 May 2012 at 06:48:40 UTC, Jonathan M Davis wrote:
> > If you make the one which isn't a ref const as well, it'll
> > probably work.
> 
>   Yeah I think so too. It will just be either a direct copy or I
> cast the object as const and pass it through. Seems like extra
> work to me and should be handled by the compiler. Anyways, thanks
> for looking at the problem with me.

With the last beta, there was a discussion in changing how ref and const ref 
works to allow rvalues while disallowing whatever use cases it is that causes 
problems with that in C++. If that gets sorted out and fully implemented, then 
you'd only need one overload. As it stands, the closest that you could get 
would be to use auto ref, but that only works with templated functions.

- Jonathan M Davis


More information about the Digitalmars-d-learn mailing list