function argument for map: why shorter form does not compile?

Ivan Kazmenko gassa at mail.ru
Sat Jun 20 14:23:18 UTC 2026


On Saturday, 20 June 2026 at 12:10:47 UTC, Nick Treleaven wrote:
> You only provided the `fmt` template argument, so `Args` is 
> inferred as an empty sequence. Your code could be supported if 
> `format` was changed to:
> ```d
> template format(alias fmt)
> {
>   typeof(fmt) format(Args...)(Args args) { ... }
> }
> ```

Hmm, but in other places, function calls do support partial 
ctargs specification.
Consider this example:

```
int fun (T1, T2) (T1 x, T2 y)
{
	return x + y;
}

int gun (T1, Args...) (T1 x, Args args)
{
	return x + args[0];
}

void main ()
{
	auto a = fun !(int) (5, 7);
	auto b = gun !(int) (5, 7);
	import std.stdio : writeln;
	writeln (a, " ", b); // 12 12
}
```

This does work, not only for `fun` with exactly one additional 
argument, but also for `gun` with variable number of additional 
arguments.  What is the difference of this case with the 
`map+format` case in the original question?

Ivan Kazmenko.



More information about the Digitalmars-d-learn mailing list