HP Integrity NonStop J-Series User Manual
Page 188

You can't use the RWDECLARE_PERSISTABLE_TEMPLATE and
RWDEFINE_PERSISTABLE_TEMPLATE macros to persist any templatized class that has
non-type template parameters. Templates with non-type template parameters, such as
RWTBitVec
, cannot be isomorphically persisted.
1.
If you have defined any of the following global operators and you use the
RWDEFINE_PERSISTABLE macro, you will get compiler ambiguity errors.
RWvostream& operator<<(RWvostream& s, const YourClass& t);
RWvistream& operator>>(RWvistream& s, YourClass& t);
RWvistream& operator>>(RWvistream& s, YourClass*& pT);
RWFile& operator<<(RWFile& s, const YourClass& t);
RWFile& operator>>(RWFile& s, YourClass& t);
RWFile& operator>>(RWFile& s, YourClass*& pT);
The compiler errors occur because using RWDEFINE_PERSISTABLE along with a different
definition of the operators defines the operators twice. This means that the compiler does not
know which operator definition to use. In this case, you have two choices:
Remove the operator<< and operator>> global functions that you previously defined for
YourClass and replace them with the operators generated by the
RWDEFINE_PERSISTABLE(YourClass).
❍
Modify your operator<< and operator>> global functions for YourClass using the
contents of the RWDEFINE_PERSISTABLE macro in rw/epersist.h as a guide.
❍
2.
Define rwSaveGuts and rwRestoreGuts
Now you must add to one and only one source file the global functions rwSaveGuts and
rwRestoreGuts, which will be used to save and restore the internal state of your class. These functions
are called by the operator<< and operator>> that were declared and defined as discussed in
RWDECLARE_PERSISTABLE to Your Header File
Add RWDEFINE_PERSISTABLE to One
above.
Writing rwSaveGuts and rwRestoreGuts Functions
provides guidelines about how to write
rwSaveGuts and rwRestoreGuts global functions.
For non-templatized classes , define the following functions:
void rwSaveGuts(RWFile& f, const YourClass& t){/*_*/}
void rwSaveGuts(RWvostream& s, const YourClass& t) {/*_*/}
void rwRestoreGuts(RWFile& f, YourClass& t) {/*_*/}
void rwRestoreGuts(RWvistream& s, YourClass& t) {/*_*/}
●
For templatized classes with a single template parameter T, define the following functions:
template
rwSaveGuts(RWFile& f, const YourClass
template
rwSaveGuts(RWvostream& s, const YourClass
template
●