On Tuesday, 21 April 2015 at 07:46:03 UTC, Vlad Levenfeld wrote:
template dimensionality (S) { template count_dim (uint i = 0) { static if (is (typeof(S.init.opSlice!i (0,0)))) enum count_dim = count_dim!(i+1); else enum count_dim = i; }alias dimensionality = count_dim!(); } Then you throw in some more stuff to detect 1-dimensional cases.
Great! I guess a template restriction on opSlice would be in Place aswell.
One thing: Why aren't you using opIndex instead? If there are types that have opIndex but not opSlice defined then dimensionality() could cover more types, right?
