Erroneous "auto can only be used for template function parameters"?

Steven Schveighoffer via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Mon Jun 22 10:50:54 PDT 2015


On 6/22/15 1:37 PM, Yuxuan Shui wrote:
> On Monday, 22 June 2015 at 13:49:21 UTC, Steven Schveighoffer wrote:
>> On 6/20/15 10:26 PM, Yuxuan Shui wrote:
>>> On Sunday, 21 June 2015 at 01:26:51 UTC, Adam D. Ruppe wrote:
>>>> On Saturday, 20 June 2015 at 01:50:11 UTC, Yuxuan Shui wrote:
>>>>> auto ref R) is indeed a template function, so I don't understand.
>>>>
>>>> But R is not a parameter on the function itself. It comes from the
>>>> outside template.
>>>>
>>>> Move it to the inside template, rewrite it as:
>>>>
>>>>     auto a(S, R)(auto ref R i) {
>>>>         return cast(S)i*2;
>>>>     }
>>>>
>>>> and you should get further.
>>>
>>> But surely nested template should be able to access outer template's
>>> parameter.
>>
>> If you have to instantiate it to see how to instantiate it, it doesn't
>> work. General rule of thumb on templates. IFTI only works at one level.
>>
> I can't see any IFTI in my code, can you point it out?

Sorry, I misunderstood what is happening here. I don't know what the 
rules are for auto ref for nested template functions, or for explicit 
instantiation.

-Steve


More information about the Digitalmars-d-learn mailing list