Ambiguous template parameter names
Meta
jared771 at gmail.com
Thu May 3 02:51:18 UTC 2018
On Thursday, 3 May 2018 at 02:48:10 UTC, jmh530 wrote:
> On Thursday, 3 May 2018 at 00:52:58 UTC, Meta wrote:
>> [snip]
>>
>> It's not a big per se. It's a consequence of the declaration
>> expanding to the real template function form (I can't type it
>> all out as I'm on my phone), thus the inner `val` from the
>> function shadows the one from the template.
>
>
> That makes sense. Before creating the example, I would have
> assumed that when you instantiate it as foo!1, then the `val=1`
> would flow through to the inner foo function.
>
> template foo(int val)
> {
> int foo(int val)
> {
> return val;
> }
> }
If you want that, you might be able to do `int val = val` on the
inner function, though I'm not sure that'll work.
More information about the Digitalmars-d-learn
mailing list