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

Ilya Yaroshenko via Digitalmars-d digitalmars-d at puremagic.com
Thu Sep 29 14:28:31 PDT 2016


On Thursday, 29 September 2016 at 20:57:00 UTC, ag0aep6g wrote:
> On 09/29/2016 10:43 PM, Ilya Yaroshenko wrote:
>> On Thursday, 29 September 2016 at 20:12:44 UTC, Walter Bright 
>> wrote:
> [...]
>>> void foo(T)(T[] a ...)
>>> {
>>>     printf("%d %d %d\n", a[0], a[1], a[2]);
>>> }
> [...]
>>
>> a.length must be known at CT. 99%-100% foreach loops in 
>> ndslice package
>> are CT.
>
> I'm not sure if I understand the goal, but what about this:
>
> void foo(size_t n)(size_t[n] a ...) { /* ... */ }

Just found an example, where this approach does not work :-(

template transposed(Dimensions...)
     if (Dimensions.length)
{
     Slice!(N, Range) transposed(size_t N, Range)(auto ref 
Slice!(N, Range) slice)
     {
         ...
     }
}


More information about the Digitalmars-d mailing list