DIP Mir1 Draft: Variadic template parameters with the same time.
Stefan Koch via Digitalmars-d
digitalmars-d at puremagic.com
Thu Sep 29 10:56:59 PDT 2016
On Thursday, 29 September 2016 at 17:24:55 UTC, Ilya Yaroshenko
wrote:
> 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)
> {
> ...
> }
> ```
This description does not tell me anything.
More information about the Digitalmars-d
mailing list