AFF --- A container for numbers (array) by Friederich and Forbriger.

◆ main()

int main ( )

testing SharedHeap

Definition at line 81 of file reprtest.cc.

References AFF_REPRTEST_CC_VERSION, CODE, DUMP, and section().

82 {
83  cout << AFF_REPRTEST_CC_VERSION << endl;
84 
85  section("array dimensions");
86  CODE( const int N=10; )
87  CODE( const int N2=23; )
88 
89  section("instantiate arrays");
90  CODE( aff::SharedHeap<int> A(N); )
91  CODE( aff::SharedHeap<int> B(N2); )
92 #ifdef SENSELESS
93 #warning intentionally compiling senseless code
94  CODE( aff::ConstSharedHeap<int> Cuseless(N2); )
95 #endif
98 
99  section("create a const reference to D");
101 
102  section("const int array should share memory with int array");
103  CODE( C=B; )
104 
105  section("fill arrays");
106  CODE( for (int i=0; i<N; i++) { A[i]=(i+1)*10; } )
107  CODE( for (int i=0; i<N2; i++) { B[i]=(i+4)*3; } )
108  CODE( for (int i=0; i<N2; i++) { D[i]=(i+2.45)*2; } )
109 
110  section("dump contents - C is filled through B and E is filled through D");
112  DUMP( B );
113  DUMP( C );
114  DUMP( E );
115 
116  section("modify C through B");
117  CODE( B[8]=632; )
118  DUMP( C );
119 
120 #ifdef ILLEGAL1
121  // you may activate this section by passing -DILLEGAL1 to the compiler
122  section("modify C directly - is illegal");
123  C[9]=354;
124  DUMP( C );
125 #endif
126 
127  section("make B a reference to A");
128  CODE( B=A; )
129  section("modification should be visible through B");
130  CODE( A[5]=453; )
131  DUMP( B );
132  section("but C holds the original values");
133  DUMP( C );
134 }
#define DUMP(A)
Dump any object through its dump function.
Definition: dump_macros.h:62
A template class to share heap memory for different array projections.
Definition: sharedheap.h:252
#define CODE(C)
Dump code and execute (works like echo)
Definition: dump_macros.h:82
void section(const char *s)
print headline
Definition: reprtest.cc:68
#define AFF_REPRTEST_CC_VERSION
Definition: reprtest.cc:44
This is the base class for const elements.
Definition: sharedheap.h:139
Here is the call graph for this function: