File: interpret4.d

package info (click to toggle)
gcc-arm-none-eabi 15%3A14.2.rel1-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 1,099,328 kB
  • sloc: cpp: 3,627,108; ansic: 2,571,498; ada: 834,230; f90: 235,082; makefile: 79,231; asm: 74,984; xml: 51,692; exp: 39,736; sh: 33,298; objc: 15,629; python: 15,069; fortran: 14,429; pascal: 7,003; awk: 5,070; perl: 3,106; ml: 285; lisp: 253; lex: 204; haskell: 135
file content (31 lines) | stat: -rw-r--r-- 726 bytes parent folder | download | duplicates (5)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
// https://issues.dlang.org/show_bug.cgi?id=11717

enum int[4] A = [1,2,3,4];
enum int[4] B = [1,2,3,4];
enum int[4] C = A[] + B[];
static assert(C == [2, 4, 6, 8]);

enum int[2] D1 = A[1..3] * B[2..4];
static assert(D1 == [6, 12]);

enum int[2] D2 = A[1..3] * 6;
static assert(D2 == [12, 18]);

enum int[2] D3 = 5 - A[1..3];
static assert(D3 == [3, 2]);

enum int[2][2] D4 = [D1, D2] + [D2, D3];
static assert(D4 == [[18, 30], [15, 20]]);

enum int[2][2] D5 = [[18, 30], [15, 20]] + [12, 18];
static assert(D5 == [[30, 48], [27, 38]]);

import core.simd;

static if (__traits(compiles, int4))
{
    enum int4 D = [1,2,3,4];
    enum int4 E = [1,2,3,4];
    enum int4 F = D * E;
    static assert(F.array == [1, 4, 9, 16]);
}