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!

Reply via email to