Non-recursive maxSizeOf

Per Nordlöw per.nordlow at gmail.com
Thu Aug 6 00:58:39 UTC 2020


Is it possible to implement

template maxSizeOf(T...)
{
     static if (T.length == 1)
         enum size_t maxSizeOf = T[0].sizeof;
     else
     {
         enum size_t firstSize = T[0].sizeof;
         enum size_t maxSizeRest = maxSizeOf!(T[1 .. $]);
         enum size_t maxSizeOf = firstSize >= maxSizeRest ? 
firstSize : maxSizeRest;
     }
}

in a non-recursive way?


More information about the Digitalmars-d-learn mailing list