Re: R-values and const ref

2010-09-15 Thread Max Samukha
On 09/09/2010 06:26 PM, Steven Schveighoffer wrote: Yes, I forgot that you are allowed to overload via ref. That would make sense for virtual functions. That forces us to provide multiple overloads, each matching one of the possible combinations of rvalue/lvalue arguments. A function with n

R-values and const ref

2010-09-09 Thread Eldar Insafutdinov
A while back dmd stopped allowing rvalues as ref function arguments. I entirely understand why it was done, but the same restriction applies to the ref const function parameters. This causes a lot of pain and at the moment makes me use pass-by-value parameters(most notably when using structs). C++

Re: R-values and const ref

2010-09-09 Thread bearophile
Eldar Insafutdinov: Can we please restore this behavior for const ref? From what I have seen D is built on different principles, so I doubt that will change. Bye, bearophile

Re: R-values and const ref

2010-09-09 Thread Steven Schveighoffer
On Thu, 09 Sep 2010 06:08:14 -0400, Eldar Insafutdinov e.insafutdi...@gmail.com wrote: A while back dmd stopped allowing rvalues as ref function arguments. I entirely understand why it was done, but the same restriction applies to the ref const function parameters. This causes a lot of pain

Re: R-values and const ref

2010-09-09 Thread dsimcha
== Quote from Eldar Insafutdinov (e.insafutdi...@gmail.com)'s article A while back dmd stopped allowing rvalues as ref function arguments. I entirely understand why it was done, but the same restriction applies to the ref const function parameters. This causes a lot of pain and at the moment

Re: R-values and const ref

2010-09-09 Thread dsimcha
== Quote from dsimcha (dsim...@yahoo.com)'s article FWIW, if you can't use templates and auto ref, there is a (slightly verbose) solution. DMD apparently allows overloading ref vs. non-ref, so you can write a forwarding function to bind to rvalues. ...except that I just realized it's broken

Re: R-values and const ref

2010-09-09 Thread Eldar Insafutdinov
I agree that auto ref may be a better option here, but I still see no reason to disallow it. It is a performance issue, not a safety one. And as you said this only works for templates, virtual functions are out of the game here. PS. opEquals issue is very annoying, indeed.

Re: R-values and const ref

2010-09-09 Thread Steven Schveighoffer
On Thu, 09 Sep 2010 11:24:14 -0400, Eldar Insafutdinov e.insafutdi...@gmail.com wrote: I agree that auto ref may be a better option here, but I still see no reason to disallow it. It is a performance issue, not a safety one. And as you said this only works for templates, virtual functions

Re: R-values and const ref

2010-09-09 Thread dsimcha
== Quote from Steven Schveighoffer (schvei...@yahoo.com)'s article On Thu, 09 Sep 2010 11:24:14 -0400, Eldar Insafutdinov e.insafutdi...@gmail.com wrote: I agree that auto ref may be a better option here, but I still see no reason to disallow it. It is a performance issue, not a safety

Re: R-values and const ref

2010-09-09 Thread Andrei Alexandrescu
On 9/9/10 6:32 CDT, Steven Schveighoffer wrote: On Thu, 09 Sep 2010 06:08:14 -0400, Eldar Insafutdinov e.insafutdi...@gmail.com wrote: A while back dmd stopped allowing rvalues as ref function arguments. I entirely understand why it was done, but the same restriction applies to the ref const

Re: R-values and const ref

2010-09-09 Thread Andrei Alexandrescu
On 9/9/10 10:43 CDT, dsimcha wrote: == Quote from Steven Schveighoffer (schvei...@yahoo.com)'s article On Thu, 09 Sep 2010 11:24:14 -0400, Eldar Insafutdinov e.insafutdi...@gmail.com wrote: I agree that auto ref may be a better option here, but I still see no reason to disallow it. It is a

Re: R-values and const ref

2010-09-09 Thread Steven Schveighoffer
On Thu, 09 Sep 2010 13:03:17 -0400, Andrei Alexandrescu seewebsiteforem...@erdani.org wrote: On 9/9/10 6:32 CDT, Steven Schveighoffer wrote: On Thu, 09 Sep 2010 06:08:14 -0400, Eldar Insafutdinov e.insafutdi...@gmail.com wrote: A while back dmd stopped allowing rvalues as ref function