Re: auto ref

2009-12-15 Thread Mikhail Dahl
On 16/12/2009 07:18, Walter Bright wrote: There's a need in generic code to have a function take a parameter by ref if it is an lvalue, and by value if it is an rvalue. This can be addressed by making it a template using auto ref: T foo(T)(auto ref T x) { ... } foo(3) // call by value int y; fo

Re: auto ref

2009-12-16 Thread Mikhail Dahl
On 16/12/2009 07:41, Walter Bright wrote: Mikhail Dahl wrote: Just to confirm (I'm just getting into D, so I don't know much about the language, still learning), but the idea is to apply 'auto' not only to types but also to storage classes? As in 'automatically apply