An example, Another example – HP Integrity NonStop J-Series User Manual
Page 135

is a portable declaration that will work with or without the Standard C++ Library. Again, do not use
a comma to separate the element type from the macro.
10.
An Example
Let's start with a simple example that uses
RWTValVector
one of the classes that is not based on the
Standard C++ Library.
#include
main() {
RWTValVector
int i;
for (i=0; i<10; i++) vec[i] = 1.0; // 3
for (i=11; i<20; i++) vec(i) = 2.0; // 4
vec.reshape(30); // 5
for (i=21; i<30; i++) vec[i] = 3.0; // 6
return 0;
}
Each program line is detailed below.
//1 This is where the template for
RWTValVector
is defined.
//2 A vector of doubles, 20 elements long and initialized to 0.0, is declared and defined.
//3 The first 10 elements of the vector are set to 1.0. Here, RWValVector
been used. This operator always performs a bounds check on its argument.
//4 The next 10 elements of the vector are set to 2.0. In this case,
RWValVector
bounds check.
//5 Member function reshape(int) changes the length of the vector.
//6 Finally, the last 10 elements are initialized to 3.0.
Another Example
The second example involves a hashing dictionary. By using the macro RWDefHArgs(T) when you
declare the hashing dictionary, you insure that your code is portable with or without access to the
Standard C++ Library.
#include
#include
#include
#include
class Count { // 1
int N;
public: