isValidOperator

正しい演算かどうか判定します

Members

Manifest constants

isValidOperator
enum isValidOperator;
Undocumented in source.
isValidOperator
enum isValidOperator;
Undocumented in source.
isValidOperator
enum isValidOperator;
Undocumented in source.
isValidOperator
enum isValidOperator;
Undocumented in source.
isValidOperator
enum isValidOperator;
Undocumented in source.
isValidOperator
enum isValidOperator;
Undocumented in source.

Examples

1 static struct S(T, size_t r, size_t c){enum rows = r; enum cols = c; T opIndex(size_t i, size_t j) const {return T.init;}}
2 alias Static1x1 = S!(int, 1, 1);
3 alias Static1x2 = S!(int, 1, 2);
4 alias Static2x1 = S!(int, 2, 1);
5 alias Static2x2 = S!(int, 2, 2);
6 
7 static struct D(T){size_t rows = 1, cols = 1; T opIndex(size_t i, size_t j) const {return T.init;}}
8 alias Dynamic = D!(int);
9 
10 static struct I(T){
11     enum rows = 0, cols = 0;
12     T opIndex(size_t i, size_t j) const { return T.init; }
13     static InferredResult inferSize(size_t rs, size_t cs){
14         if(rs == 0 && cs == 0)
15             return InferredResult(false, 0, 0);
16         else if(rs == 0 || cs == 0)
17             return InferredResult(true, max(rs, cs), max(rs, cs));
18         else
19             return InferredResult(true, rs, cs);
20     }
21 }
22 alias Inferable = I!int;
23 static assert(Inferable.inferSize(1, 0).isValid);
24 
25 alias T = Inferable;
26 static assert(T.rows == wild);
27 static assert(T.cols == wild);
28 
29 
30 static assert( isValidOperator!(Static1x1, "+", Static1x1));
31 static assert(!isValidOperator!(Static1x1, "+", Static1x2));
32 static assert( isValidOperator!(Static1x2, "+", Static1x2));
33 static assert(!isValidOperator!(Static1x2, "+", Static1x1));
34 
35 static assert( isValidOperator!(Static1x1, "+", Dynamic));
36 static assert( isValidOperator!(Static1x2, "+", Dynamic));
37 static assert( isValidOperator!(Dynamic, "+", Static1x1));
38 static assert( isValidOperator!(Dynamic, "+", Static1x2));
39 
40 static assert( isValidOperator!(Static1x1, "+", Inferable));
41 static assert( isValidOperator!(Static1x2, "+", Inferable));
42 static assert( isValidOperator!(Inferable, "+", Static1x1));
43 static assert( isValidOperator!(Inferable, "+", Static1x2));
44 
45 static assert( isValidOperator!(Static1x1, "*", Static1x1));
46 static assert( isValidOperator!(Static1x1, "*", Static1x2));
47 static assert(!isValidOperator!(Static1x2, "*", Static1x2));
48 static assert(!isValidOperator!(Static1x2, "*", Static1x1));
49 
50 static assert( isValidOperator!(Static1x1, "*", Dynamic));
51 static assert( isValidOperator!(Static1x2, "*", Dynamic));
52 static assert( isValidOperator!(Dynamic, "*", Static1x1));
53 static assert( isValidOperator!(Dynamic, "*", Static1x2));
54 
55 static assert( isValidOperator!(Static1x1, "*", Inferable));
56 static assert( isValidOperator!(Static1x2, "*", Inferable));
57 static assert( isValidOperator!(Inferable, "*", Static1x1));
58 static assert( isValidOperator!(Inferable, "*", Static1x2));

Meta