The OpenD Programming Language

mir_slice.elementCount

struct mir_slice(Iterator_, size_t N_ = 1, SliceKind kind_ = Contiguous, Labels_...)
@safe @property scope const
size_t
elementCount
()
()
if (
0 < N_ &&
N_ < 255
&&
!(
kind_ == Canonical &&
N_ == 1
)
&&
Labels_.length <= N_
&&
isIterator!Iterator_
)

Return Value

Type: size_t

Total number of elements in a slice

Examples

Regular slice

import mir.ndslice.topology : iota;
assert(iota(3, 4, 5).elementCount == 60);

Packed slice

import mir.ndslice.topology : pack, evertPack, iota;
auto slice = iota(3, 4, 5, 6, 7, 8);
auto p = slice.pack!2;
assert(p.elementCount == 360);
assert(p[0, 0, 0, 0].elementCount == 56);
assert(p.evertPack.elementCount == 56);

Meta