DIP Mir1 Draft: Variadic template parameters with the same time.
Ilya Yaroshenko via Digitalmars-d
digitalmars-d at puremagic.com
Thu Sep 29 15:05:13 PDT 2016
On Thursday, 29 September 2016 at 22:03:36 UTC, ag0aep6g wrote:
> On 09/29/2016 11:28 PM, Ilya Yaroshenko wrote:
>> [...]
> [...]
>> [...]
>
> When the values themselves are known at compile time, we can
> convert them to size_t before generating the function:
>
> ----
> enum isIndex(T) = is(T == size_t); /* by pineapple */
> enum asIndex(size_t value) = value;
>
> template transposed(Dimensions...)
> if (Dimensions.length)
> {
> import std.meta: allSatisfy, staticMap;
> static if (allSatisfy!(isIndex, typeof(Dimensions)))
> {
> void transposed() {} /* simplified for the example */
> }
> else
> {
> alias transposed = transposed!(staticMap!(asIndex,
> Dimensions));
> }
> }
>
> alias t1 = transposed!(1, 2, 3);
> alias t2 = transposed!(1LU, 2LU, 3LU);
>
> static assert(&t1 == &t2); /* passes */
> ----
Thanks again!
More information about the Digitalmars-d
mailing list