isVector

ベクトル型かどうか判定します

enum bool isVector(T);

Examples

ベクトル型かどうか判定します

1 static struct V
2 {
3     enum rows = 1;
4     enum cols = 3;
5     enum length = 3;
6 
7     auto opIndex(size_t i, size_t j) const { return j; }
8     auto opIndex(size_t j) const { return j; }
9 
10     alias at = opIndex;
11 }
12 
13 static assert(isMatrix!V);
14 static assert(isNarrowMatrix!V);
15 static assert(isVector!V);
16 static assert(!isAbstractMatrix!V);
17 static assert(isNarrowVector!V);
18 
19 static assert(isVector!(int[]));
20 static assert(isVector!(int[][]));
21 static assert(isVector!(int[][1]));
22 static assert(isVector!(int[1][]));
1 import std.bigint, std.typetuple;
2 alias TT = TypeTuple!(ubyte, ushort, uint, ulong,
3                        byte,  short,  int,  long,
4                       float, double, real,
5                       creal, cfloat, cdouble/*,*/
6                       /*BigInt*/);
7 
8 static struct M(T, size_t r, size_t c)
9 {
10     enum rows = r;
11     enum cols = c;
12 
13     auto opIndex(size_t i, size_t j) const { return T.init; }
14     alias at = opIndex;
15 }
16 
17 foreach(T; TT)
18 {
19     static assert(isNarrowMatrix!(M!(T, 3, 3)));
20     static assert(isNarrowMatrix!(M!(const(T), 3, 3)));
21     static assert(isNarrowMatrix!(M!(immutable(T), 3, 3)));
22     static assert(isMatrix!(M!(T, 3, 3)));
23     static assert(isMatrix!(M!(const(T), 3, 3)));
24     static assert(isMatrix!(M!(immutable(T), 3, 3)));
25 }

Meta