auto ref and non-templated functions

Andrei Alexandrescu SeeWebsiteForEmail at erdani.org
Tue Dec 25 06:09:13 PST 2012


On 12/25/12 12:34 AM, Zhenya wrote:
> On Tuesday, 25 December 2012 at 01:40:16 UTC, Peter Alexander wrote:
>> On Tuesday, 25 December 2012 at 00:56:44 UTC, Peter Alexander wrote:
>>> On Monday, 24 December 2012 at 17:40:54 UTC, Jonathan M Davis wrote:
>>>> And if that doesn't work, can we simply make it so that the compiler
>>>> automatically creates a variable when you pass an rvalue to a
>>>> non-templated
>>>> auto ref function?
>>>
>>> I don't see any problems with this, but I admittedly haven't thought
>>> too much about it.
>>
>> If there are no problems with this way, then what I want to know is
>> why the template version of auto ref wasn't implemented this way. The
>> way auto ref is currently implemented for templates is a bit of a mess.
> Maybe it's difficult to generate both versions because for the function
> like this
>
> void foo(auto ref S s1,auto ref S s2,...,auto ref s10)
>
> compiler should generate 2^10 versions of function foo.

The compiler will only generate as many versions as there are compatible 
calls.

Andrei


More information about the Digitalmars-d mailing list