Using templates without the standard library – HP Integrity NonStop J-Series User Manual
Page 134

Click on the banner to return to the user guide home page.
©Copyright 1996 Rogue Wave Software
Using Templates Without the Standard Library
Several of the Tools.h++ templates, such as
RWTValVector
,
RWTPtrVector
,
RWTIsvSlist
,
and
RWTIsvDlist
, are not based on the Standard C++ Library. You can use them on any of our
certified platforms. Also, as mentioned previously in the Introduction, you can use many of the so-called
standard library-based templates without the Standard C++ Library, as long as you keep to a subset of the
full interface.
Keeping the Standard C++ Library in Mind for Portability
The restricted subset interfaces are almost fully upward compatible with their corresponding standard
library-based interfaces. The major difference you will find is that some collections take a different
number of template parameters, depending on which underlying implementation they are using. For
example, when
RWTPtrHashSet
is used with the Standard C++ Library, it takes three template arguments
above. However, when that same class is used without the
Standard C++ Library, the restricted interface calls for only one template parameter, namely the type of
item being contained. To help you write portable code that works with or without the Standard C++
Library, Tools.h++ provides two macros:
Use the first macro, RWDefHArgs(T), standing for Rogue Wave Default Hash Arguments, for the
hash-based template collections. For example, by declaring:
1.
RWTPtrHashSet
2.
you declare a hash-based set that will have the same semantics whether or not the Standard C++
Library is present. Note that you should not use a comma between the element type and the macro.
Without the Standard C++ Library, the macro expands to nothing and it is as if you had declared:
3.
RWTPtrHashSet
4.
However, as soon as the Standard C++ Library becomes available, the macro expands as follows:
5.
RWTPtrHashSet
6.
This declaration satisfies the full requirement of the standard library-based interface for all three
parameters, and keeps the semantics consistent with the alternative non standard-library based
implementation.
7.
The second macro, RWDefCArgs(T), is similar to the first. Standing for Rogue Wave Default
Comparison Arguments, RWDefCArgs(T)is available for use with
RWTPtrSortedVector
and
RWTValSortedVector
. For example:
8.
RWTValSortedVector
9.