DIP Mir1 Draft: Variadic template parameters with the same time.

Ilya Yaroshenko via Digitalmars-d digitalmars-d at puremagic.com
Thu Sep 29 10:24:55 PDT 2016


Problem

Most ndslice API accepts variadic list of integers.
The following code example shows how `slice` and `[a, b, c]`
can generate 64 identical functions each.

```
// (1, 1U, 1UL, 1L) x
// (2, 2U, 2UL, 2L) x
// (3, 3U, 3UL, 3L) = 4 ^^ 3 = 64 identical variants
auto cube = slice!double(1, 2, 3);

size_t i;
sizediff_t j;
int k;
uint p;
// 64 identical variants for 64-bit with i, j, k, p
auto v = cube[i, j, k];
```
------------------------

Solution

T[] can be added to a template variadic name.

```
void foo(size_t[] Index...)(Indexes index)
{
     ...
}
```


More information about the Digitalmars-d mailing list