ADT
aaron-thesis
arm-eh
ast-experimental
cleanup-dtors
deferred_resn
demangler
enum
forall-pointer-decay
jacob/cs343-translation
jenkins-sandbox
new-ast
new-ast-unique-expr
no_list
persistent-indexer
pthread-emulation
qualifiedEnum
Last change
on this file since a8615fd1 was 23c4aa8, checked in by Rob Schluntz <rschlunt@…>, 9 years ago |
fix constructor transitivity rule
|
-
Property mode
set to
100644
|
File size:
1.0 KB
|
Line | |
---|
1 | //
|
---|
2 | // Cforall Version 1.0.0 Copyright (C) 2015 University of Waterloo
|
---|
3 | //
|
---|
4 | // The contents of this file are covered under the licence agreement in the
|
---|
5 | // file "LICENCE" distributed with Cforall.
|
---|
6 | //
|
---|
7 | // simpleGenericTriple.c --
|
---|
8 | //
|
---|
9 | // Author : Rob Schluntz
|
---|
10 | // Created On : Tue Nov 15 17:24:32 2016
|
---|
11 | // Last Modified By : Rob Schluntz
|
---|
12 | // Last Modified On : Tue Nov 15 17:27:28 2016
|
---|
13 | // Update Count : 3
|
---|
14 | //
|
---|
15 |
|
---|
16 | forall(otype T)
|
---|
17 | struct T3 {
|
---|
18 | T f0, f1, f2;
|
---|
19 | };
|
---|
20 |
|
---|
21 | forall(otype T | { T ?+?(T, T); })
|
---|
22 | T3(T) ?+?(T3(T) x, T3(T) y) {
|
---|
23 | T3(T) z = { x.f0+y.f0, x.f1+y.f1, x.f2+y.f2 };
|
---|
24 | return z;
|
---|
25 | }
|
---|
26 |
|
---|
27 | int main() {
|
---|
28 | int x1 = 123, x3 = 456;
|
---|
29 | double x2 = 999.123;
|
---|
30 | struct T3(int) Li = { x1, (int)x2, x3 };
|
---|
31 | struct T3(int) Ri = { 9, 2, 3 };
|
---|
32 | struct T3(int) reti = Li+Ri;
|
---|
33 | printf("%d %d %d\n", reti.f0, reti.f1, reti.f2);
|
---|
34 |
|
---|
35 | struct T3(double) Ld = { x1, x2, x3 };
|
---|
36 | struct T3(double) Rd = { 9, 2, 3 };
|
---|
37 | struct T3(double) retd = Ld+Rd;
|
---|
38 | printf("%g %g %g\n", retd.f0, retd.f1, retd.f2);
|
---|
39 | }
|
---|
40 |
|
---|
41 | // Local Variables: //
|
---|
42 | // tab-width: 4 //
|
---|
43 | // End: //
|
---|
Note:
See
TracBrowser
for help on using the repository browser.